<%--<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>--%>
<%--<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>--%>
<%--<!DOCTYPE html>--%>
<%--<html lang="en" xmlns:th="http://www.thymeleaf.org">--%>
<%--<head>--%>
<%--    <meta charset="UTF-8">--%>
<%--    <title>login</title>--%>
<%--</head>--%>
<%--<body>--%>
<%--<form action="/user/loginService" method="post">--%>
<%--  <label>请输入用户名：<input name="username" type="text"></label><BR>--%>
<%--  <label>请输入密码：<input name="password" type="password"></label><BR>--%>
<%--  <input type="submit" value="登录">--%>
<%--</form>--%>
<%--<a href="/page/toRegisterPage">没有账号？注册一个</a>--%>
<%--</body>--%>
<%--</html>--%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f7f7f7;
            margin: 0;
        }
        .myTab {
            border: 1px solid #ddd;
            border-collapse: collapse;
            background-color: #fff;
            padding: 20px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
            border-radius: 15px; /* 圆角 */
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 50vh;
        }
        .myTab form {
            width: 100%;
        }
        td {
            padding: 10px;
            text-align: center;
        }
        input[type="text"],
        input[type="password"],
        select {
            width: 100%;
            padding: 8px;
            margin: 5px 0;
            border: 1px solid #ccc;
            border-radius: 5px; /* 圆角 */
        }
        input[type="submit"] {
            padding: 10px 15px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 5px; /* 圆角 */
            cursor: pointer;
            margin-top: 10px; /* 顶部间距 */
            float: right;
        }
        input[type="submit"]:hover {
            background-color: #036ad5;

        }
        a {
            margin-top: 10px; /* 顶部间距 */
            text-decoration: none;
            color: #007bff;
        }
        a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<div class="myTab">
    <form action="/user/loginService" method="post" onsubmit="return validateForm()">
        <tr>
            <td><label>请输入用户名：</label></td>
            <td><input name="username" type="text"></td>
        </tr>
        <tr>
            <td><label>请输入密码：</label></td>
            <td><input name="password" type="password"></td>
        </tr>
        <tr>
            <td><label>选择身份：</label></td>
            <td>
                <select name="role">
                    <option value="user">普通用户</option>
                    <option value="admin">管理员</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center;"><input type="submit" value="登录"></td>
        </tr>
    </form>
    <a href="/page/toRegisterPage">没有账号？注册一个</a>
</div>

<script>
    function validateForm() {
        var username = document.forms[0]["username"].value;
        var password = document.forms[0]["password"].value;
        if (username == "" || password == "") {
            alert("用户名和密码不能为空！");
            return false;
        }
        return true;


    }
</script>
</body>
</html>
